
package gui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;

import model.Node;

class TreeRenderer extends DefaultTreeCellRenderer implements TreeCellRenderer
{

   public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row,
      boolean hasFocus)
   {
      JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

      Node node = (Node) value;

      if (leaf)
         component.setForeground(Color.BLUE);
      else
         component.setForeground(Color.BLACK);

      component.setIcon(node.getIcon());
      return component;
   }
}